home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / rfc / rfc542 < prev    next >
Text File  |  1991-04-20  |  101KB  |  2,475 lines

  1.  
  2.  
  3.  
  4.  
  5. < NIC-WORK, NIC-FTP.NLS;26, >, 19-MAR-76 14:08 JAKE ;;;;
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                    1
  64.  
  65.                                                   File Transfer Protocol
  66.                                                          (Aug. 12, 1973)
  67.                                                        RFC 542 NIC 17759
  68.  
  69.  
  70. Nancy J. Neigus                            See Also:  RFCs 354, 454, 495
  71. Bolt Beranek and Newman, Inc.
  72. Cambridge, Mass.
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.               File Transfer Protocol for the ARPA Network
  97.  
  98.                                                   File Transfer Protocol
  99.                                                          (Aug. 12, 1973)
  100.                                                        RFC 542 NIC 17759
  101.  
  102.  
  103.                                 PREFACE
  104.  
  105. This document is the result of several months discussion via RFC
  106. (relevant numbers are 430, 448, 454, 463, 468, 478, 480), followed by a
  107. meeting of the FTP committee at BBN on March 16, followed by further
  108. communication among committee members.  There are a considerable number
  109. of changes for the last "official" version, see RFCs 354, 385, but the
  110. gross structure remains the same.  The places to look for differences
  111. are (1) in the definitions pf types and modes, (2) in the specification
  112. of the data connection and data sockets, (3) in the command-reply
  113. sequences, (4) in the functions dependent on the TELNET protocol (FTP
  114. has been altered to correspond to the new TELNET spec).  The model has
  115. been clarified and enlarged to allow inter-server file transfer, and
  116. several new commands have been added to accommodate more specialized (or
  117. site-specific) functions.  It is my belief that this new specificiation
  118. reflects the views expressed by the committee at the above-mentioned
  119. meeting and in subsequent conversations.
  120.  
  121. The large number of incompatibilities would complicate a phased
  122. implementation schedule, such as is in effect for the TELNET protocol.
  123. Therefore we have assigned a new socket, decimal 21, as a temporary
  124. logger socket for the new version and a change-over date of 1 February
  125. 1974.  Until that date the old (354, 385) version of FTP will be
  126. available on Socket 3 and the new version (attached) should be
  127. implemented on Socket 21.  On 1 February the new version will shift to
  128. Socket 3 and the old disappear from view.
  129.  
  130. The File Transfer protocol should be considered stable at least until
  131. February, though one should feel free to propose further changes via
  132. RFC.  (Implementation of new commands on an experimental basis is
  133. encouraged and should also be reported by RFC.)  In addition, members of
  134. the FTP committee may be contacted directly about changes.  Based on
  135. attendance at the March 16 meeting, they are:
  136.  
  137.    Abhay Bhushan MIT-DMCG
  138.    Bob Braden UCLA-CCN
  139.    Bob Bressler BBN-NET
  140.    Bob Clements BBN-TENEX
  141.    John Day ILL-ANTS
  142.    Peter Deutsch PARC-MAXC
  143.    Wayne Hathaway AMES-67
  144.    Mike Kudlick SRI-ARC
  145.    Alex McKenzie BBN-NET
  146.    Bob Merryman UCSD-CC
  147.    Nancy Neigus BBN-NET
  148.    Mike Padlipsky MIT-Multics
  149.    Jim Pepin USC-44
  150.    Ken Pogran MIT-Multics
  151.    Jon Postel UCLA-NMC
  152.  
  153.  
  154.  
  155.  
  156.  
  157.                                    1
  158.  
  159.                                                   File Transfer Protocol
  160.                                                          (Aug. 12, 1973)
  161.                                                        RFC 542 NIC 17759
  162.                                                                         
  163.                                                                         
  164.    Milton Reese FNWC
  165.    Brad Reussow HARV-10
  166.    Marc Seriff MIT-DMCG
  167.    Ed Taft HARV-10
  168.    Bob Thomas BBN-TENEX
  169.    Ric Werme CMU-10
  170.    Jim White SRI-ARC
  171.  
  172. I would especially like to thank Bob Braden, Ken Pogran, Wayne Hathaway,
  173. Jon Postel, Ed Taft and Alex McKenzie for their help in preparing this
  174. document.
  175.  
  176. NJN/jm
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.                                    2
  219.  
  220.                                                   File Transfer Protocol
  221.                                                          (Aug. 12, 1973)
  222.                                                        RFC 542 NIC 17759
  223.                                                                         
  224.                                                                         
  225.                          FILE TRANSFER PROTOCOL
  226.  
  227. INTRODUCTION
  228.  
  229.    The File Transfer Protocol (FTP) is a protocol for file transfer
  230.    between Hosts (including Terminal Interface Message Processors
  231.    (TIPs)) on the ARPA Computer Network (ARPANET).  The primary function
  232.    of FTP is to transfer files efficiently and reliably among Hosts and
  233.    to allow the convenient use of remote file storage capabilities.
  234.  
  235.    The objectives of FTP are 1) to promote sharing of files (computer
  236.    programs and/or data), 2) to encourage indirect or implicit (via
  237.    programs) use of remote computers, 3) to shield a user from
  238.    variations in file storage systems among Hosts, and 4) to transfer
  239.    data reliably and efficiently.  FTP, though usable directly by a user
  240.    at a terminal, is designed mainly for use by programs.
  241.  
  242.    The attempt in this specification is to satisfy the diverse needs of
  243.    users of maxi-Hosts, mini-Hosts, TIPs, and the Datacomputer, with a
  244.    simple, and easily implemented protocol design.
  245.  
  246.    This paper assumes knowledge of the following protocols described in
  247.    NIC #7104:
  248.  
  249.       The Host-Host Protocol
  250.  
  251.       The Initial Connection Protocol
  252.  
  253.       The TELNET Protocol
  254.  
  255. DISCUSSION
  256.  
  257.    In this section, the terminology and the FTP model are discussed.
  258.    The terms defined in this section are only those that have special
  259.    significance in FTP.
  260.  
  261.    TERMINOLOGY
  262.  
  263.       ASCII
  264.  
  265.          The USASCII character set as defined in NIC #7104.  In FTP,
  266.          ASCII characters are defined to be the lower half of an
  267.          eight-bit code set (i.e., the most significant bit is zero).
  268.  
  269.       access controls
  270.  
  271.          Access controls define users' access privileges to the use of a
  272.          system, and to the files in that system.  Access controls are
  273.          necessary to prevent unauthorized or accidental use of files.
  274.  
  275.  
  276.  
  277.  
  278.  
  279.                                    3
  280.  
  281.                                                   File Transfer Protocol
  282.                                                          (Aug. 12, 1973)
  283.                                                        RFC 542 NIC 17759
  284.                                                                         
  285.                                                                         
  286.          It is the prerogative of a server-FTP process to provide access
  287.          controls.
  288.  
  289.       byte size
  290.  
  291.          The byte size specified for the transfer of data.  The data
  292.          connection is opened with this byte size.  The data connection
  293.          byte size is not necessarily the byte size in which data is to
  294.          be stored in a system, nor the logical byte size for
  295.          interpretation of the structure of the data.
  296.  
  297.       data connection
  298.  
  299.          A simplex connection over which data is transferred, in a
  300.          specified byte size, mode and type. The data transferred may be
  301.          a part of a file, an entire file or a number of files.  The
  302.          path may be between a server-DTP and a user-DTP, or between two
  303.          server-DTPs.
  304.  
  305.       data socket
  306.  
  307.          The passive data transfer process "listens" on the data socket
  308.          for an RFC from the active transfer process (server) in order
  309.          to open the data connection.  The server has fixed data
  310.          sockets; the passive process may or may not.
  311.  
  312.       EOF
  313.  
  314.          The end-of-file condition that defines the end of a file being
  315.          transferred.
  316.  
  317.       EOR
  318.  
  319.          The end-of-record condition that defines the end of a record
  320.          being transferred.
  321.  
  322.       error recovery
  323.  
  324.          A procedure that allows a user to recover from certain errors
  325.          such as failure of either Host system or transfer process.  In
  326.          FTP, error recovery may involve restarting a file transfer at a
  327.          given checkpoint.
  328.  
  329.       FTP commands
  330.  
  331.          A set of commands that comprise the control information flowing
  332.          from the user-FTP to the server-FTP process.
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.                                    4
  341.  
  342.                                                   File Transfer Protocol
  343.                                                          (Aug. 12, 1973)
  344.                                                        RFC 542 NIC 17759
  345.                                                                         
  346.                                                                         
  347.       file
  348.  
  349.          An ordered set of computer data (including programs), of
  350.          arbitrary length, uniquely identified by a pathname.
  351.  
  352.       mode
  353.  
  354.          The mode in which data is to be transferred via the data
  355.          connection. The mode defines the data format during transfer
  356.          including EOR and EOF.  The transfer modes defined in FTP are
  357.          described in the Section on Transmission Modes.
  358.  
  359.       NVT
  360.  
  361.          The Network Virtual Terminal as defined in the ARPANET TELNET
  362.          Protocol.
  363.  
  364.       NVFS
  365.  
  366.          The Network Virtual File System.  A concept which defines a
  367.          standard network file system with standard commands and
  368.          pathname conventions.  FTP only partially embraces the NVFS
  369.          concept at this time.
  370.  
  371.       pathname
  372.  
  373.          Pathname is defined to be the character string which must be
  374.          input to a file system by a user in order to identify a file.
  375.          Pathname normally contains device and/or directory names, and
  376.          file name specification.  FTP does not yet specify a standard
  377.          pathname convention.  Each user must follow the file naming
  378.          conventions of the file systems he wishes to use.
  379.  
  380.       record
  381.  
  382.          A sequential file may be structured as a number of contiguous
  383.          parts called records.  Record structures are supported by FTP
  384.          but a file need not have record structure.
  385.  
  386.       reply
  387.  
  388.          A reply is an acknowledgment (positive or negative) sent from
  389.          server to user via the TELNET connections in response to FTP
  390.          commands.  The general form of a reply is a completion code
  391.          (including error codes) followed by a text string.  The codes
  392.          are for use by programs and the text is usually intended for
  393.          human users.
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.                                    5
  402.  
  403.                                                   File Transfer Protocol
  404.                                                          (Aug. 12, 1973)
  405.                                                        RFC 542 NIC 17759
  406.                                                                         
  407.                                                                         
  408.       server-DTP
  409.  
  410.          The data transfer process, in its normal "active" state,
  411.          establishes the data connection by RFC to the "listening" data
  412.          socket, sets up parameters for transfer and storage, and
  413.          tranfers data on command from its PI.  The DTP can be placed in
  414.          a "passive" state to listen for, rather than initiate, an RFC
  415.          on the data socket.
  416.  
  417.       server-FTP process
  418.  
  419.          A process or set of processes which perform the function of
  420.          file transfer in cooperation with a user-FTP process and,
  421.          possibly, another server.  The functions consist of a protocol
  422.          interpreter (PI) and a data transfer process (DTP).
  423.  
  424.       server-PI
  425.  
  426.          The protocol interpreter "listens" on Socket 3 for an ICP from
  427.          a user-PI and establishes a TELNET communication connection.
  428.          It receives standard FTP commands from the user-PI, sends
  429.          replies, and governs the server-DTP.
  430.  
  431.       TELNET connections
  432.  
  433.          The full-duplex communication path between a user-PI and a
  434.          server-PI.  The TELNET connections are established via the
  435.          standard ARPANET Initial Connection Protocol (ICP).
  436.  
  437.       type
  438.  
  439.          The data representation type used for data transfer and
  440.          storage.  Type implies certain transformations between the time
  441.          of data storage and data transfer.  The representation types
  442.          defined in FTP are described in the Section on Establishing
  443.          Data Connections.
  444.  
  445.       user
  446.  
  447.          A human being or a process on behalf of a human being wishing
  448.          to obtain file transfer service.  The human user may interact
  449.          directly with a server-FTP process, but use of a user-FTP
  450.          process is preferred since the protocol design is weighted
  451.          towards automata.
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.                                    6
  463.  
  464.                                                   File Transfer Protocol
  465.                                                          (Aug. 12, 1973)
  466.                                                        RFC 542 NIC 17759
  467.                                                                         
  468.                                                                         
  469.       user-DTP
  470.  
  471.          The data transfer process "listens" on the data socket for an
  472.          RFC from a server-FTP process.  If two servers are transferring
  473.          data between them, the user-DTP is inactive.
  474.  
  475.       user-FTP process
  476.  
  477.          A set of functions including a protocol interpreter, a data
  478.          transfer process and a user interface which together perform
  479.          the function of file transfer in cooperation with one or more
  480.          server-FTP processes.  The user interface allows a local
  481.          language to be used in the command-reply dialogue with the
  482.          user.
  483.  
  484.       user-PI
  485.  
  486.          The protocol interpreter initiates the ICP to the server-FTP
  487.          process, initiates FTP commands, and governs the user-DTP if
  488.          that process is part of the file transfer.
  489.  
  490.    THE FTP MODEL
  491.  
  492.    With the above definitions in mind, the following model (shown in
  493.    Figure 1) may be diagrammed for an FTP service.
  494.  
  495.                                          -------------
  496.                                          !/---------\!
  497.                                          !!   User  !!    --------
  498.                                          !!Interface!<--->! User !
  499.                                          !\----:----/!    --------
  500.                ----------                !     V     !
  501.                !/------\!  FTP Commands  !/---------\!
  502.                !!Server!<-----------------!   User  !!
  503.                !!  PI  !----------------->!    PI   !!
  504.                !\--:---/!   FTP Replies  !\----:----/!
  505.                !   V    !                !     V     !
  506.    --------    !/------\!      Data      !/---------\!    --------
  507.    ! File !<--->!Server!<---------------->!  User   !<--->! File !
  508.    !System!    !! DTP  !!   Connections  !!   DTP   !!    !System!
  509.    --------    !\------/!                !\---------/!    --------
  510.                ----------                -------------
  511.  
  512.                Server-FTP                   User-FTP
  513.  
  514.    NOTES: 1. The data connection may be in either direction.
  515.           2. The data connection need not exist all of the time.
  516.  
  517.                      Figure 1  Model for FTP Use
  518.  
  519.  
  520.  
  521.  
  522.  
  523.                                    7
  524.  
  525.                                                   File Transfer Protocol
  526.                                                          (Aug. 12, 1973)
  527.                                                        RFC 542 NIC 17759
  528.                                                                         
  529.                                                                         
  530.    In the model described in Figure 1, the user-protocol interpreter
  531.    initiates the TELNET connections. At the initiation of the user,
  532.    standard FTP commands are generated by the user-PI and transmitted to
  533.    the server process via the TELNET connections.  (The user may
  534.    establish a direct TELNET connection to the server-FTP, from a TIP
  535.    terminal for example, and generate standard FTP commands himself,
  536.    by-passing the user-FTP process.) Standard replies are sent from the
  537.    server-PI to the user-PI over the TELNET connections in response to
  538.    the commands.
  539.  
  540.    The FTP commands specify the parameters for the data connection (data
  541.    socket, byte size, transfer mode, representation type, and structure)
  542.    and the nature of file system operation (store, retrieve, append,
  543.    delete, etc.).  The user-DTP or its designate should "listen" on the
  544.    specified data socket, and the server initiate the data connection
  545.    and data transfer in accordance with the specified parameters.  It
  546.    should be noted that the data socket need not be in the same Host
  547.    that initiates the FTP commands via the TELNET connections, but the
  548.    user or his user-FTP process must ensure a "listen" on the specified
  549.    data socket.  It should also be noted that two data connections, one
  550.    for send and the other for receive, may exist simultaneously.
  551.  
  552.    In another situation a user might wish to transfer files between two
  553.    Hosts, neither of which is his local Host. He sets up TELNET
  554.    connections to the two servers and then arranges for a data
  555.    connection between them.  In this manner control information is
  556.    passed to the user-PI but data is transferred between he server data
  557.    transfer processes.  Following is a model of this server-server
  558.    interaction.
  559.  
  560.    
  561.                  TELNET     ------------    TELNET
  562.                  -----------! User-FTP !------------
  563.                  ! -------->! User-PI  !<--------- !
  564.                  ! !        !   "C"    !         ! !
  565.                  V !        ------------         ! V
  566.          --------------                        --------------
  567.          ! Server-FTP !   Data Connection      ! Server-FTP !
  568.          !    "A"     !<-----------------------!    "B"     !
  569.          -------------- Socket(A)    Socket(B) --------------
  570.    
  571.    
  572.    
  573.                              Figure 2
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.                                    8
  585.  
  586.                                                   File Transfer Protocol
  587.                                                          (Aug. 12, 1973)
  588.                                                        RFC 542 NIC 17759
  589.  
  590.  
  591.    The protocol requires that the TELNET connections be open while data
  592.    transfer is in progress.  It is the responsibility of the user to
  593.    request the closing of the TELNET connections when finished using the
  594.    FTP service, while it is the server who takes the action.  The server
  595.    may abort data transfer if the TELNET connections are closed without
  596.    command.
  597.  
  598. DATA TRANSFER FUNCTIONS
  599.  
  600.    Files are transferred only via the data connection(s).  The TELNET
  601.    connection is used for the transfer of commands, which describe the
  602.    functions to be performed, and the replies to these commands (see the
  603.    Section on FTP Replies).  Several commands are concerned with the
  604.    transfer of data between Hosts.  These data transfer commands include
  605.    the BYTE, MODE, and SOCKet commands which specify how the bits of the
  606.    data are to be transmitted, and the STRUcture and TYPE commands,
  607.    which are used to define the way in which the data are to be
  608.    represented. The transmission and representation are basically
  609.    independent but "Stream" transmission mode is dependent on the file
  610.    structure attribute and if "Compressed" transmission mode is used the
  611.    nature of the filler byte depends on the representation type.
  612.  
  613.    DATA REPRESENTATION AND STORAGE
  614.  
  615.    Data is transferred from a storage device in the sending Host to a
  616.    storage device in the receiving Host.  Often it is necessary to
  617.    perform certain transformations on the data because data storage
  618.    representations in the two systems are different.  For example,
  619.    NVT-ASCII has different data storage representations in diffeent
  620.    systems.  PDP-10's generally store NVT-ASCII as five 7-bit ASCII
  621.    characters, left-justified in a 36-bit word. 360's store NVT-ASCII as
  622.    8-bit EBCDIC codes. Multics stores NVT-ASCII as four 9-bit characters
  623.    in a 36-bit word.  It may be desirable to convert characters into the
  624.    standard NVT-ASCII representation when transmitting text between
  625.    dissimilar systems.  The sending and receiving sites would have to
  626.    perform the necessary transformations between the standard
  627.    representation and their internal representations.
  628.  
  629.    A different problem in representation arises when transmitting binary
  630.    data (not character codes) between Host systems with different word
  631.    lengths.  It is not always clear how the sender should send data, and
  632.    the receiver store it.  For example, when transmitting 32-bit bytes
  633.    from a 32-bit word-length system to a 36-bit word-length system, it
  634.    may be desirable (for reasons of efficiency and usefulness) to store
  635.    the 32-bit bytes right-justified in a 36-bit word in the latter
  636.    system.  In any case, the user should have the option of specifying
  637.    data representation and transformation functions.  It should be noted
  638.    that FTP provides for very limited data type representations.
  639.    Transformations desired beyond this limited capability should be
  640.  
  641.  
  642.  
  643.  
  644.  
  645.                                    9
  646.  
  647.                                                   File Transfer Protocol
  648.                                                          (Aug. 12, 1973)
  649.                                                        RFC 542 NIC 17759
  650.  
  651.  
  652.    performed by the user directly or via the use of the Data
  653.    Reconfiguration Sevice (DRS, RFC #138, NIC #6715).  Additonal
  654.    representation types may be defined later if there is a demonstrable
  655.    need.
  656.  
  657.    Data representations are handled in FTP by a user specifying a
  658.    representation type.  This type may implicitly (as in ASCII or
  659.    EBCDIC) or explicitly (as in Local byte) define a byte size for
  660.    interpretation which is referred to as the "logical byte size."  This
  661.    has nothing to do with the byte size used for transmission over the
  662.    data connection(s) (called the "transfer byte size") and the two
  663.    should not be confused.  For example, NVT-ASCII has a logical byte
  664.    size of 8 bits but an ASCII file might be transferred using a
  665.    transfer byte size of 32.  If the type is Local byte, then the TYPE
  666.    command has an obligatory second parameter specifying the logical
  667.    byte size.
  668.  
  669.    The types ASCII and EBCDIC also take a second (optional) parameter;
  670.    this is to indicate what kind of vertical format control, if any, is
  671.    associated with a file.  The following data representation types are
  672.    defined in FTP:
  673.  
  674.       ASCII Format
  675.  
  676.          This is the default type and must be accepted by all FTP
  677.          implementations.  It is intended primarily for the transfer of
  678.          text files, except when both Hosts would find the EBCDIC type
  679.          more convenient.
  680.  
  681.          The sender converts the data from his internal character
  682.          representation to the standard 8-bit NVT-ASCII representation
  683.          (see the TELNET specification).  The receiver will convert the
  684.          data from the standard form to his own internal form.
  685.  
  686.          In accordance with the NVT standard, the <CRLF> sequence should
  687.          be used, where necessary, to denote the end of a line of text.
  688.          (See the discussion of file structure at the end of the Section
  689.          on Data Representation and Storage).
  690.  
  691.          Using the standard NVT-ASCII representation means that data
  692.          must be interpreted as 8-bit bytes.  If the BYTE command (see
  693.          the Section on Transfer Parameter Commands) specifies a
  694.          transfer byte size different from 8 bits, the 8-bit ASCII
  695.          characters should be packed contiguously without regard for
  696.          transfer byte boundaries.
  697.  
  698.          The Format parameter for ASCII and EBCDIC types is discussed
  699.          below.
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.                                    10
  707.  
  708.                                                   File Transfer Protocol
  709.                                                          (Aug. 12, 1973)
  710.                                                        RFC 542 NIC 17759
  711.                                                                         
  712.                                                                         
  713.       EBCDIC Format
  714.  
  715.          This type is intended for efficient transfer between Hosts
  716.          which use EBCDIC for their internal character representation.
  717.  
  718.          For transmission the data are represented as 8-bit EBCDIC
  719.          characters.  The character code is the only difference between
  720.          the functional specifications of EBCDIC and ASCII types.
  721.  
  722.          End-of-line (as opposed to end-of-record--see the discussion of
  723.          structure) will probably be rarely used with EBCDIC type for
  724.          purposes of denoting structure, but where it is necessary the
  725.          <NL> character should be used.
  726.  
  727.    A character file may be transferred to a Host for one of three
  728.    purposes: for printing, for storage and later retrieval, or for
  729.    processing.  If a file is sent for printing, the receiving Host must
  730.    know how the vertical format control is represented.  In the second
  731.    case, it must be possible to store a file at a Host and then retrieve
  732.    it later in exactly the same form.  Finally, it ought to be possible
  733.    to move a file from one Host to another and process the file at the
  734.    second Host without undue trouble.  A single ASCII or EBCDIC format
  735.    does not satisfy all these conditions and so these types have a
  736.    second parameter specifying one of the following three formats:
  737.  
  738.       Non-print
  739.  
  740.          This is the default format to be used if the second (format)
  741.          parameter is omitted.  Non-print format must be accepted by all
  742.          FTP implementations.
  743.  
  744.          The file need contain no vertical format information.  If it is
  745.          passed to a printer process, this process may assume standard
  746.          values for spacing and margins.
  747.  
  748.          Normally, this format will be used with files destined for
  749.          processing or just storage.
  750.  
  751.       TELNET Format Controls
  752.  
  753.          The file contains ASCII/EBCDIC vertical format controls (i.e.,
  754.          <CR>, <LF>, <NL>, <VT>, <FF>) which the printer process will
  755.          interpret appropriately.  <CRLF>, in exactly this sequence,
  756.          also denotes end-of-line.
  757.  
  758.       Carriage Control (ASA)
  759.  
  760.          The file contains ASA (FORTRAN) vertical format control
  761.          characters.  (See NWG/RFC #189 Appendix C and Communications of
  762.  
  763.  
  764.  
  765.  
  766.  
  767.                                    11
  768.  
  769.                                                   File Transfer Protocol
  770.                                                          (Aug. 12, 1973)
  771.                                                        RFC 542 NIC 17759
  772.                                                                         
  773.                                                                         
  774.          the ACM, Vol. 7, No. 10, 606 (Oct. 1964)).  In a line or a
  775.          record, formatted according to the ASA Standard, the first
  776.          character is not to be printed.  Instead it should be used to
  777.          determine the vertical movement of the paper which should take
  778.          place before the rest of the record is printed.  The ASA
  779.          Standard specifies the following control characters:
  780.  
  781.             Character     Vertical Spacing
  782.  
  783.             blank         Move paper up one line
  784.             0             Move paper up two lines
  785.             1             Move paper to top of next page
  786.             +             No movement, i.e., overprint
  787.  
  788.          Clearly there must be some way for a printer process to
  789.          distinguish the end of the structural entity.  If a file has
  790.          record structure (see below) this is no problem; records will
  791.          be explicitly marked during transfer and storage.  If the file
  792.          has no record structure, the <CRLF> end-of-line sequence is
  793.          used to separate printing lines, but these format effectors are
  794.          overridden by the ASA controls.
  795.  
  796.       Image
  797.  
  798.          The data are sent as contiguous bits which, for transfer, are
  799.          packed into transfer bytes of the size specified in the BYTE
  800.          command.  The receiving site must store the data as contiguous
  801.          bits.  The structure of the storage system might necessitate
  802.          the padding of the file (or of each record, for a
  803.          record-structured file) to some convenient boundary (byte, word
  804.          or block).  This padding, which must be all zeroes, may occur
  805.          only at the end of the file (or at the end of each record) and
  806.          there must be a way of identifying the padding bits so that
  807.          they may be stripped off if the file is retrieved.  The padding
  808.          transformation should be well publicized to enable a user to
  809.          process a file at the storage site.
  810.  
  811.          Image type is intended for the efficient storage and retrieval
  812.          of files and for the transfer of binary data.  It is
  813.          recommended that this type be accepted by all FTP
  814.          implementations.
  815.  
  816.       Local byte Byte size
  817.  
  818.          The data is transferred in logical bytes of the size specified
  819.          by the obligatory second parameter, Byte size.  The value of
  820.          Byte size must be a decimal integer; there is no default value.
  821.          The logical byte size is not necessarily the same as the
  822.          transfer byte size.  If there is a difference in byte sizes,
  823.  
  824.  
  825.  
  826.  
  827.  
  828.                                    12
  829.  
  830.                                                   File Transfer Protocol
  831.                                                          (Aug. 12, 1973)
  832.                                                        RFC 542 NIC 17759
  833.                                                                         
  834.                                                                         
  835.          then the logical bytes should be packed contiguously,
  836.          disregarding transfer byte boundaries and with any necessary
  837.          padding at the end.
  838.  
  839.          When the data reaches the receiving Host it will be transformed
  840.          in a manner dependent on the logical byte size and the
  841.          particular Host.  This transformation must be invertible (that
  842.          is an identical file can be retrieved if the same parameters
  843.          are used) and should be well publicized by the FTP
  844.          implementors.
  845.  
  846.          This type is intended for the transfer of structured data.  For
  847.          example, a user sending 36-bit floating-point numbers to a Host
  848.          with a 32-bit word could send his data as Local byte with a
  849.          logical byte size of 36.  The receiving Host would then be
  850.          expected to store the logical bytes so that they could be
  851.          easily manipulated; in this example putting the 36-bit logical
  852.          bytes into 64-bit double words should suffice.
  853.  
  854.    A note of caution about parameters:  a file must be stored and
  855.    retrieved with the same parameters if the retrieved version is to be
  856.    identical to the version originally transmitted.  Conversely, FTP
  857.    implementations must return a file identical to the original if the
  858.    parameters used to store and retrieve a file are the same.
  859.  
  860.    In addition to different representation types, FTP allows the
  861.    structure of a file to be specified.  Currently two file structures
  862.    are recognized in FTP: file-structure, where there is no internal
  863.    structure, and record-structure, where the file is made up of
  864.    records.  File-structure is the default, to be assumed if the
  865.    STRUcture command has not been used but both structures must be
  866.    accepted for "text" files (i.e., files with TYPE ASCII or EBCDIC) by
  867.    all FTP implementations.  The structure of a file will affect both
  868.    the transfer mode of a file (see the Section on Transmission Modes)
  869.    and the interpretation and storage of the file.
  870.  
  871.    The "natural" structure of a file will depend on which Host stores
  872.    the file.  A source-code file will usually be stored on an IBM 360 in
  873.    fixed length records but on a PDP-10 as a stream of characters
  874.    partitioned into lines, for example by <CRLF>.  If the transfer of
  875.    files between such disparate sites is to be useful, there must be
  876.    some way for one site to recognize the other's assumptions about the
  877.    file.
  878.  
  879.    With some sites being naturally file-oriented and others naturally
  880.    record-oriented there may be problems if a file with one structure is
  881.    sent to a Host oriented to the other.  If a text file is sent with
  882.    record-structure to a Host which is file oriented, then that Host
  883.    should apply an internal transformation to the file based on the
  884.  
  885.  
  886.  
  887.  
  888.  
  889.                                    13
  890.  
  891.                                                   File Transfer Protocol
  892.                                                          (Aug. 12, 1973)
  893.                                                        RFC 542 NIC 17759
  894.                                                                         
  895.                                                                         
  896.    record structure.  Obviously this transformation should be useful but
  897.    it must also be invertible so that an identical file may be
  898.    retreieved using record structure.
  899.  
  900.    In the case of a file being sent with file-structure to a
  901.    record-oriented Host, there exists the question of what criteria the
  902.    Host should use to divide the file into records which can be
  903.    processed locally.  If this division is necessary the FTP
  904.    implementation should use the end-of-line sequence, <CRLF> for ASCII,
  905.    or <NL> for EBCDIC text files, as the delimiter.  If an FTP
  906.    implementation adopts this technique, it must be prepared to reverse
  907.    the transformation if the file is retrieved with file-structure.
  908.  
  909.    ESTABLISHING DATA CONNECTIONS
  910.  
  911.    The mechanics of transferring data consists of setting up the data
  912.    connection to the appropriate sockets and choosing the parameters for
  913.    transfer--byte size and mode. Both the user and the server-DTPs have
  914.    default data sockets; these are the two sockets (for send and
  915.    receive) immediately following the standard ICP TELNET socket ,i.e.,
  916.    (U+4) and (U+5) for the user-process and (S+2), (S+3) for the server.
  917.    The use of default sockets will ensure the security of the data
  918.    transfer, without requiring the socket information to be explicitly
  919.    exchanged.
  920.  
  921.    The byte size for the data connection is specified by the BYTE
  922.    command, or, if left unspecified, defaults to 8-bit bytes.  This byte
  923.    size is relevant only for the actual transfer of the data; it has no
  924.    bearing on representation of the data within a Host's file system.
  925.    The protocol does not require servers to accept all possible byte
  926.    sizes. Since the use of various byte sizes is intended for efficiency
  927.    of transfer, servers may implement only those sizes for which their
  928.    data transfer is efficient including the default byte size of 8 bits.
  929.  
  930.    The passive data transfer process (this may be a user-DTP or a second
  931.    server-DTP) shall "listen" on the data socket prior to sending a
  932.    transfer request command.  The FTP request command determines the
  933.    direction of the data transfer and thus which data socket (odd or
  934.    even) is to be used in establishing the connection.  The server, upon
  935.    receiving the transfer request, will initiate the data connection by
  936.    RFC to the appropriate socket using the specified (or default) byte
  937.    size.  When the connection is opened, the data transfer begins
  938.    between DTP's, and the server-PI sends a confirming reply to the
  939.    user-PI.
  940.  
  941.    It is possible for the user to specify an alternate data socket by
  942.    use of the SOCK command.  He might want a file dumped on a TIP line
  943.    printer or retrieved from a third party Host.  In the latter case the
  944.    user-PI sets up TELNET connections with both server-PI's and sends
  945.  
  946.  
  947.  
  948.  
  949.  
  950.                                    14
  951.  
  952.                                                   File Transfer Protocol
  953.                                                          (Aug. 12, 1973)
  954.                                                        RFC 542 NIC 17759
  955.                                                                         
  956.                                                                         
  957.    each a SOCK command indicating the fixed data sockets of the other.
  958.    One server is then told (by an FTP command) to "listen" for an RFC
  959.    which the other will initiate and finally both are sent the
  960.    appropriate transfer commands.  The exact sequence of commands and
  961.    replies sent between the user-controller and the servers is defined
  962.    in the Section on FTP Replies.
  963.  
  964.    In general it is the server's responsibility to maintain the data
  965.    connection--to initiate the RFC's and the closes.  The exception to
  966.    this is when the user-DTP is sending the data in a transfer mode that
  967.    requires the connection to be closed to indicate EOF.  The server
  968.    MUST close the data connection under the following conditions:
  969.  
  970.       1. The server has completed sending data in a transfer mode that
  971.          requires a close to indicate EOF.
  972.  
  973.       2. The server receives an ABORT command from the user.
  974.  
  975.       3. The socket or byte size specification is changed by a command
  976.          from the user.
  977.  
  978.       4. The TELNET connections are closed legally or otherwise.
  979.  
  980.       5. An irrecoverable error condition occurs.
  981.  
  982.    Otherwise the close is a server option, the exercise of which he must
  983.    indicate to the user-process by an appropriate reply.
  984.  
  985.    TRANSMISSION MODES
  986.  
  987.    The next consideration in transferring data is choosing the
  988.    appropriate transmission mode.  There are three modes: one which
  989.    formats the data and allows for restart procedures; one which also
  990.    compresses the data for efficient transfer; and one which passes the
  991.    data with little or no processing.  In this last case the mode
  992.    interacts with the structure attribute to determine the type of
  993.    processing.  In the compressed mode the representation type
  994.    determines the filler byte.
  995.  
  996.    All data transfers must be completed with an end-of-file (EOF) which
  997.    may be explicitly stated or implied by the closing of the data
  998.    connection.  For files with record structure, all the end-of-record
  999.    markers (EOR) are explicit, including the final one.
  1000.  
  1001.    Note:  In the rest of this section, byte means "transfer byte" except
  1002.    where explicitly stated otherwise.
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.                                    15
  1012.  
  1013.                                                   File Transfer Protocol
  1014.                                                          (Aug. 12, 1973)
  1015.                                                        RFC 542 NIC 17759
  1016.                                                                         
  1017.                                                                         
  1018.    The following transmission modes are defined in FTP:
  1019.  
  1020.       Stream
  1021.  
  1022.          The data is transmitted as a stream of bytes.  There is no
  1023.          restriction on the representation type used; record structures
  1024.          are allowed, in which case the transfer byte size must be at
  1025.          least 3 bits!
  1026.  
  1027.          In a record structured file EOR and EOF will each be indicated
  1028.          by a two-byte control code of whatever byte size is used for
  1029.          the transfer.  The first byte of the control code will be all
  1030.          ones, the escape character.  The second byte will have the low
  1031.          order bit on and zeroes elsewhere for EOR and the second low
  1032.          order bit on for EOF; that is, the byte will have value 1 for
  1033.          EOR and value 2 for EOF.  EOR and EOF may be indicated together
  1034.          on the last byte transmitted by turning both low order bits on,
  1035.          i.e., the value 3.  If a byte of all ones was intended to be
  1036.          sent as data, it should be repeated in the second byte of the
  1037.          control code.
  1038.  
  1039.          If the file does not have record structure, the EOF is
  1040.          indicated by the sending Host closing the data connection and
  1041.          all bytes are data bytes.
  1042.  
  1043.    For the purpose of standardized transfer, the sending Host will
  1044.    translate his internal end of line or end of record denotation into
  1045.    the representation prescribed by the transfer mode and file
  1046.    structure, and the receiving Host will perform the inverse
  1047.    translation to his internal denotation.  An IBM 360 record count
  1048.    field may not be recognized at another Host, so the end of record
  1049.    information may be transferred as a two byte control code in Stream
  1050.    mode or as a flagged bit in a Block or Compressed mode descriptor.
  1051.    End of line in an ASCII or EBCDIC file with no record structure
  1052.    should be indicated by <CRLF> or <NL>, respectively.  Since these
  1053.    transformations imply extra work for some systems, identical systems
  1054.    transferring non-record structured text files might wish to use a
  1055.    binary representation and stream mode for the transfer.
  1056.  
  1057.       Block
  1058.  
  1059.          The file is transmitted as a series of data blocks preceded by
  1060.          one or more header bytes.  The header bytes contain a count
  1061.          field, and descriptor code.  The count field indicates the
  1062.          total length of the data block in bytes, thus marking the
  1063.          beginning of the next data block (there are no filler bits).
  1064.          The descriptor code defines:  last block in the file (EOF) last
  1065.          block in the record (EOR), restart marker (see the Section on
  1066.          Error Recovery and Restart) or suspect data (i.e., the data
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.                                    16
  1073.  
  1074.                                                   File Transfer Protocol
  1075.                                                          (Aug. 12, 1973)
  1076.                                                        RFC 542 NIC 17759
  1077.  
  1078.  
  1079.          being transferred is suspected of errors and is not reliable).
  1080.          This last code is NOT intended for error control within FTP.
  1081.          It is motivated by the desire of sites exchanging certain types
  1082.          of data (e.g., seismic or weather data) to send and receive all
  1083.          the data despite local errors (such as "magnetic tape read
  1084.          errors"), but to indicate in the transmission that certain
  1085.          portions are suspect).  Record structures are allowed in this
  1086.          mode, and any representation type may be used.  There is no
  1087.          restriction on the transfer byte size.
  1088.  
  1089.          The header consists of the smallest integral number of bytes
  1090.          whose length is greater than or equal to 24 bits.  Only the
  1091.          LEAST significant 24 bits (right-justified) of header shall
  1092.          have information; the remaining most significant bits are
  1093.          "don't care" bits.  Of the 24 bits of header information, the
  1094.          16 low order bits shall represent byte count, and the 8 high
  1095.          order bits shall represent descriptor codes as shown below.
  1096.  
  1097.          Integral number of bytes greater than or equal to 24 bits
  1098.          --------------------------------------------------------
  1099.          !    Don't care    !    Descriptor    !    Byte Count  !
  1100.          !  0 to 231 bits   !      8 bits      !     16 bits    !
  1101.          --------------------------------------------------------
  1102.          
  1103.  
  1104.          The descriptor codes are indicated by bit flags in the
  1105.          descriptor byte.  Four codes have been assigned, where each
  1106.          code number is the decimal value of the corresponding bit in
  1107.          the byte.
  1108.  
  1109.             Code     Meaning
  1110.             
  1111.              128     End of data block is EOR
  1112.               64     End of data block is EOF
  1113.               32     Suspected errors in data block
  1114.               16     Data block is a restart marker
  1115.             
  1116.  
  1117.          With this encoding more than one descriptor coded condition may
  1118.          exist for a particular block.  As many bits as necessary may be
  1119.          flagged.
  1120.  
  1121.          The restart marker is embedded in the data stream as an
  1122.          integral number of 8-bit bytes representing printable
  1123.          characters in the language being used over the TELNET
  1124.          connection (e.g., default--NVT-ASCII).  These marker bytes are
  1125.          right-justified in the smallest integral number of transfer
  1126.          bytes greater than or equal to 8 bits.  For example, if the
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.                                    17
  1134.  
  1135.                                                   File Transfer Protocol
  1136.                                                          (Aug. 12, 1973)
  1137.                                                        RFC 542 NIC 17759
  1138.                                                                         
  1139.                                                                         
  1140.          byte size is 7 bits, the restart marker byte would be one byte
  1141.          right-justified per two 7-bit bytes as shown below:
  1142.  
  1143.                  Two 7-bit bytes
  1144.             -------------------------
  1145.             !        !  Marker Char !
  1146.             !        !     8 bits   !
  1147.             -------------------------
  1148.  
  1149.          If the transfer byte size is 16 or more bits, the maximum
  1150.          possible number of complete marker bytes should be packed,
  1151.          right-justified, into each transfer byte.  The restart marker
  1152.          should begin in the first marker byte.  If there are any unused
  1153.          marker bytes, these should be filled with the character <SP>
  1154.          (Space, in the appropriate language).  <SP> must not be used
  1155.          WITHIN a restart marker.  For example, to transmit a
  1156.          six-character marker with a 36-bit transfer byte size, the
  1157.          following three 36-bit bytes would be sent:
  1158.  
  1159.             ------------------------------------------
  1160.             ! Don't care !Descriptor! Byte count = 2 !
  1161.             !   12 bits  ! code = 16!                !
  1162.             ------------------------------------------
  1163.             
  1164.             ------------------------------------------
  1165.             !    ! Marker ! Marker ! Marker ! Marker !
  1166.             !    ! 8 bits ! 8 bits ! 8 bits ! 8 bits !
  1167.             ------------------------------------------
  1168.             
  1169.             ------------------------------------------
  1170.             !    ! Marker ! Marker ! Space  ! Space  !
  1171.             !    ! 8 bits ! 8 bits ! 8 bits ! 8 bits !
  1172.             ------------------------------------------
  1173.             
  1174.  
  1175.       Compressed
  1176.  
  1177.          The file is transmitted as series of bytes of the size
  1178.          specified by the BYTE command.  There are three kinds of
  1179.          information to be sent:  regular data, sent in a byte string;
  1180.          compressed data, consisting of replications or filler; and
  1181.          control information, sent in a two-byte escape sequence.  If
  1182.          the byte size is B bits and n>0 bytes of regular data are sent,
  1183.          these n bytes are preceded by a byte with the left-most bit set
  1184.          to 0 and the right-most B-1 bits containing the number n.
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.                                    18
  1195.  
  1196.                                                   File Transfer Protocol
  1197.                                                          (Aug. 12, 1973)
  1198.                                                        RFC 542 NIC 17759
  1199.                                                                         
  1200.                                                                         
  1201.                         1  B-1    B        B
  1202.                        -------  ------   ------
  1203.          Byte string:  !0! n !  !d(1)!...!d(n)!
  1204.                        -------  ------   ------
  1205.                                 ^             ^
  1206.                                 !---n bytes---!
  1207.                                     of data
  1208.  
  1209.             String of n data bytes d(1),..., d(n)
  1210.             Count n must be positive
  1211.  
  1212.          To compress a string of n replications of the data byte d, the
  1213.          following 2 bytes are sent:
  1214.  
  1215.          
  1216.                               2     B-2       B
  1217.                            ---------------  ------
  1218.          Replicated Byte:  ! 1 0 !   n   !  ! d  !
  1219.                            ---------------  ------
  1220.  
  1221.          A string of n filler bytes can be compressed into a single
  1222.          byte, where the filler byte varies with the representation
  1223.          type.  If the type is ASCII or EBCDIC the filler byte is <SP>
  1224.          (Space, ASCII code 32., EBCDIC code 64).  If the transfer byte
  1225.          size is not 8, the expanded byte string should be filled with
  1226.          8-bit <SP> characters in the manner described in the definition
  1227.          of ASCII representation type (see the Section on Data
  1228.          Representation and Storage).  If the type is Image or Local
  1229.          byte the filler is a zero byte.
  1230.  
  1231.                             2     B-2
  1232.                          ---------------
  1233.          Filler String:  ! 1 1 !   n   !
  1234.                          ---------------
  1235.  
  1236.          The escape sequence is a double byte, the first of which is the
  1237.          escape byte (all zeroes) and the second of which contains
  1238.          descriptor codes as defined in Block mode.  This implies that
  1239.          the byte size must be at least 8 bits, which is not much of a
  1240.          restriction for efficiency in this mode.  The descriptor codes
  1241.          have the same meaning as in Block mode and apply to the
  1242.          succeeding string of bytes.
  1243.  
  1244.          Compressed mode is useful for obtaining increased bandwidth on
  1245.          very large network transmissions at a little extra CPU cost.
  1246.          It is most efficient when the byte size chosen is that of the
  1247.          word size of the transmitting Host, and can be most effectively
  1248.          used to reduce the size of printer files such as those
  1249.          generated by RJE Hosts.
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.                                    19
  1256.  
  1257.                                                   File Transfer Protocol
  1258.                                                          (Aug. 12, 1973)
  1259.                                                        RFC 542 NIC 17759
  1260.                                                                         
  1261.                                                                         
  1262.    ERROR RECOVERY AND RESTART
  1263.  
  1264.    There is no provision for detecting bits lost or scrambled in data
  1265.    transfer.  This issue is perhaps handled best at the NCP level where
  1266.    it benefits most users.  However, a restart procedure is provided to
  1267.    protect users from gross system failures (including failures of a
  1268.    Host, an FTP-process, or the IMP subnet).
  1269.  
  1270.    The restart procedure is defined only for the block and compressed
  1271.    modes of data transfer.  It requires the sender of data to insert a
  1272.    special marker code in the data stream with some marker information.
  1273.    The marker information has meaning only to the sender, but must
  1274.    consist of printable characters in the default or negotiated language
  1275.    of the TELNET connection.  The marker could represent a bit-count, a
  1276.    record-count, or any other information by which a system may identify
  1277.    a data checkpoint.  The receiver of data, if it implements the
  1278.    restart procedure, would then mark the corresponding position of this
  1279.    marker in the recieving system, and return this information to the
  1280.    user.
  1281.  
  1282.    In the event of a system failure, the user can restart the data
  1283.    transfer by identifying the marker point with the FTP restart
  1284.    procedure.  The following example illustrates the use of the restart
  1285.    procedure.
  1286.  
  1287.    The sender of the data inserts an appropriate marker block in the
  1288.    data stream at a convenient point.  The receiving Host marks the
  1289.    corresponding data point in its file system and conveys the last
  1290.    known sender and receiver marker information to the user, either
  1291.    directly or over the TELNET connection in a 251 reply (depending on
  1292.    who is the sender).  In the event of a system failure, the user or
  1293.    controller process restarts the server at the last server marker by
  1294.    sending a restart command with server's marker code as its argument.
  1295.    The restrart command is transmitted over the TELNET connection and is
  1296.    immediately followed by the command (such as RETR, STOR or LIST)
  1297.    which was being executed when the system failure occurred.
  1298.  
  1299. FILE TRANSFER FUNCTIONS
  1300.  
  1301.    The communication channel from the user-PI to the server-PI is
  1302.    established by ICP from the user to a standard server socket.  The
  1303.    user protocol interpreter is responsible for sending FTP commands and
  1304.    interpreting the replies received; the server-PI interprets commands,
  1305.    sends replies and directs its DTP to set up the data connection and
  1306.    transfer the data.  If the second party to the data transfer (the
  1307.    passive transfer process) is the user-DTP then it is governed through
  1308.    the internal protocol of the user-FTP Host; if it is a second
  1309.    server-DTP then it is governed by its PI on command from the user-PI.
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.                                    20
  1317.  
  1318.                                                   File Transfer Protocol
  1319.                                                          (Aug. 12, 1973)
  1320.                                                        RFC 542 NIC 17759
  1321.                                                                         
  1322.                                                                         
  1323.    FTP COMMANDS
  1324.  
  1325.    The File Transfer Protocol follows the specifications of the TELNET
  1326.    protocol for all communications over the TELNET connection - see NIC
  1327.    #7104.  Since, in the future, the language used for TELNET
  1328.    communication may be a negotiated option, all references in the next
  1329.    two sections will be to the "TELNET language" and the corresponding
  1330.    "TELNET end of line code".  Currently one may take these to mean
  1331.    NVT-ASCII and <CRLF>.  No other specifications of the TELNET protocol
  1332.    will be cited.
  1333.  
  1334.    FTP commands are "TELNET strings" terminated by the "TELNET end of
  1335.    line code".  The command codes themselves are alphabetic characters
  1336.    terminated by the character <SP> (Space) if parameters follow and
  1337.    TELNET-EOL otherwise.  The command codes and the semantics of
  1338.    commands are described in this section; the detailed syntax of
  1339.    commands is specified in the Section on Commands, the reply sequences
  1340.    are discussed in the Section on Sequencing of Commands and Replies,
  1341.    and scenarios illustrating the use of commands are provided in the
  1342.    Section on Typical FTP Scenarios.
  1343.  
  1344.    FTP commands may be partitioned as those specifying access-control
  1345.    identifiers, data transfer parameters, or FTP service requests.
  1346.    Certain commands (such as ABOR, STAT, BYE) may be sent over the
  1347.    TELNET connections while a data transfer is in progress.  Some
  1348.    servers may not be able to monitor the TELNET and data connections
  1349.    simultaneously, in which case some special action will be necessary
  1350.    to get the server's attention.  The exact form of the "special
  1351.    action" is related to decisions currently under review by the TELNET
  1352.    committee; but the following ordered format is tentatively
  1353.    recommended:
  1354.  
  1355.       1. User system inserts the TELNET "Interrupt Process" (IP) signal
  1356.          in the TELNET stream.
  1357.  
  1358.       2. User system sends the TELNET "Synch" signal
  1359.  
  1360.       3. User system inserts the command (e.g., ABOR) in the TELNET
  1361.          stream.
  1362.  
  1363.       4. Server PI,, after receiving "IP", scans the TELNET stream for
  1364.          EXACTLY ONE FTP command.
  1365.  
  1366.    (For other servers this may not be necessary but the actions listed
  1367.    above should have no unusual effect.)
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.                                    21
  1378.  
  1379.                                                   File Transfer Protocol
  1380.                                                          (Aug. 12, 1973)
  1381.                                                        RFC 542 NIC 17759
  1382.                                                                         
  1383.                                                                         
  1384.    ACCESS CONTROL COMMANDS
  1385.  
  1386.    The following commands specify access control identifiers (command
  1387.    codes are shown in parentheses).
  1388.  
  1389.       USER NAME (USER)
  1390.  
  1391.          The argument field is a TELNET string identifying the user.
  1392.          The user identification is that which is required by the server
  1393.          for access to its file system.  This command will normally be
  1394.          the first command transmitted by the user after the TELNET
  1395.          connections are made (some servers may require this).
  1396.          Additional identification information in the form of a password
  1397.          and/or an account command may also be required by some servers.
  1398.          Servers may allow a new USER command to be entered at any point
  1399.          in order to change the access control and/or accounting
  1400.          information.  This has the effect of flushing any user,
  1401.          password, and account information already supplied and
  1402.          beginning the login sequence again.  All transfer parameters
  1403.          are unchanged and any file transfer in progress is completed
  1404.          under the old acccount.
  1405.  
  1406.       PASSWORD (PASS)
  1407.  
  1408.          The argument field is a TELNET string identifying the user's
  1409.          password.  This command must be immediately preceded by the
  1410.          user name command, and, for some sites, completes the user's
  1411.          identification for access control.  Since password information
  1412.          is quite sensitive, it is desirable in general to "mask" it or
  1413.          suppress typeout.  It appears that the server has no foolproof
  1414.          way to achieve this.  It is therefore the responsibility of the
  1415.          user-FTP process to hide the sensitive password information.
  1416.  
  1417.       ACCOUNT (ACCT)
  1418.  
  1419.          The argument field is a TELNET string identifying the user's
  1420.          account.  The command is not necessarily related to the USER
  1421.          command, as some sites may require an account for login and
  1422.          others only for specific access, such as storing files.  In the
  1423.          latter case the command may arrive at any time.  There are two
  1424.          reply codes to differentiate these cases for the automaton:
  1425.          when account information is required for login, the response to
  1426.          a successful PASSword command is reply code 331; then if a
  1427.          command other than ACCounT is sent, the server may remember it
  1428.          and return a 331 reply, prepared to act on the command after
  1429.          the account information is received; or he may flush the
  1430.          command and return a 433 reply asking for the account.  On the
  1431.          other hand, if account information is NOT required for login,
  1432.          the reply to a successful PASSword command is 230; and if the
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.                                    22
  1439.  
  1440.                                                   File Transfer Protocol
  1441.                                                          (Aug. 12, 1973)
  1442.                                                        RFC 542 NIC 17759
  1443.  
  1444.  
  1445.          information is needed for a command issued later in the
  1446.          dialogue, the server should return a 331 or 433 reply depending
  1447.          on whether he stores (pending receipt of the ACCounT command)
  1448.          or discards the command, respectively.
  1449.  
  1450.       REINITIALIZE (REIN)
  1451.  
  1452.          This command terminates a USER, flushing all I/O and account
  1453.          information, except to allow any transfer in progress to be
  1454.          completed.  All parameters are reset to the default settings
  1455.          and the TELNET connection is left open.  This is identical to
  1456.          the state in which a user finds himself immediately after the
  1457.          ICP is completed and the TELNET connections are opened.  A USER
  1458.          command may be expected to follow.
  1459.  
  1460.       LOGOUT (BYE)
  1461.  
  1462.          This command terminates a USER and if file transfer is not in
  1463.          progress, the server closes the TELNET connection.  If file
  1464.          transfer is in progress, the connection will remain open for
  1465.          result response and the server will then close it.  If the
  1466.          user-process is transferring files for several USERs but does
  1467.          not wish to close and then reopen connections for each, then
  1468.          the REIN command should be used instead of BYE.
  1469.  
  1470.          An unexpected close on the TELNET connection will cause the
  1471.          server to take the effective action of an abort (ABOR) and a
  1472.          logout (BYE).
  1473.  
  1474.    TRANSFER PARAMETER COMMANDS
  1475.  
  1476.    All data transfer parameters have default values, and the commands
  1477.    specifying data transfer parameters are required only if the default
  1478.    parameter values are to be changed.  The default value is the last
  1479.    specified value, or if no value has been specified, the standard
  1480.    default value as stated here.  This implies that the server must
  1481.    "remember" the applicable default values.  The commands may be in any
  1482.    order except that they must precede the FTP service request.  The
  1483.    following commands specify data transfer parameters.
  1484.  
  1485.       BYTE SIZE (BYTE)
  1486.  
  1487.          The argument is a decimal integer (1 through 255) specifying
  1488.          the byte size for the data connection.  The default byte size
  1489.          is 8 bits.  A server may reject certain byte sizes that he has
  1490.          not implemented.
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.                                    23
  1500.  
  1501.                                                   File Transfer Protocol
  1502.                                                          (Aug. 12, 1973)
  1503.                                                        RFC 542 NIC 17759
  1504.                                                                         
  1505.                                                                         
  1506.       DATA SOCKET (SOCK)
  1507.  
  1508.          The argument is a HOST-SOCKET specification for the data socket
  1509.          to be used in data connection.  There may be two data sockets,
  1510.          one for transfer from the "active" DTP to the "passive" DTP and
  1511.          one for "passive" to "active".  An odd socket number defines a
  1512.          send socket and an even socket number defines a receive socket.
  1513.          The default HOST is the user Host to which TELNET connections
  1514.          are made.  The default data sockets are (U+4) and (U+5) where U
  1515.          is the socket number used in the TELNET ICP and the TELNET
  1516.          connections are on sockets (U+2) and (U+3).  The server has
  1517.          fixed data sockets (S+2) and (S+3) as well, and under normal
  1518.          circimstances this command and its reply are not needed.
  1519.  
  1520.       PASSIVE (PASV)
  1521.  
  1522.          This command requests the server-DTP to "listen" on both of his
  1523.          data sockets and to wait for an RFC to arrive for one socket
  1524.          rather than initiate one upon receipt of a transfer command.
  1525.          It is assumed the server has already received a SOCK command to
  1526.          indicate the foreign socket from which the RFC will arrive to
  1527.          ensure the security of the transfer.
  1528.  
  1529.       REPRESENTATION TYPE (TYPE)
  1530.  
  1531.          The argument specifies the representation type as described in
  1532.          the Section on Data Representation and Storage.  Several types
  1533.          take a second parameter.  The first parameter is denoted by a
  1534.          single TELNET character, as is the second Format parameter for
  1535.          ASCII and EBCDIC; the second parameter for local byte is a
  1536.          decimal integer to indicate Bytesize.  The parameters are
  1537.          separated by a <SP> (Space, ASCII code 32.).  The following
  1538.          codes are assigned for type:
  1539.  
  1540.             
  1541.                       \    /
  1542.             A - ASCII !    ! N - Non-print
  1543.                       !-><-! T - TELNET format effectors
  1544.             E - EBCDIC!    ! C - Carriage Control (ASA)
  1545.                       /    \
  1546.             I - Image
  1547.             
  1548.             L # - Local byte Bytesize
  1549.             
  1550.             
  1551.  
  1552.          The default representation type is ASCII Non-print.  If the
  1553.          Format parameter is changed, and later just the first argument
  1554.          is changed, Format then returns to the Non-print default.
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.                                    24
  1561.  
  1562.                                                   File Transfer Protocol
  1563.                                                          (Aug. 12, 1973)
  1564.                                                        RFC 542 NIC 17759
  1565.                                                                         
  1566.                                                                         
  1567.       FILE STRUCTURE (STRU)
  1568.  
  1569.          The argument is a single TELNET character code specifying file
  1570.          structure described in the Section on Data Representation and
  1571.          Storage.  The following codes are assigned for structure:
  1572.  
  1573.             F - File (no record structure)
  1574.             R - Record structure
  1575.  
  1576.          The default structure is File  (i.e., no records).
  1577.  
  1578.       TRANSFER MODE (MODE)
  1579.  
  1580.          The argument is a single TELNET character code specifying the
  1581.          data transfer modes described in the Section on Transmission
  1582.          Modes.  The following codes are assigned for transfer modes:
  1583.  
  1584.             S - Stream
  1585.             B - Block
  1586.             C - Compressed
  1587.  
  1588.          The default transfer mode is Stream.
  1589.  
  1590.    FTP SERVICE COMMANDS
  1591.  
  1592.    The FTP service commands define the file transfer or the file system
  1593.    function requested by the user.  The argument of an FTP service
  1594.    command will normally be a pathname.  The syntax of pathnames must
  1595.    conform to server site conventions (with standard defaults
  1596.    applicable), and the language conventions of the TELNET connection.
  1597.    The suggested default handling is to use the last specified device,
  1598.    directory or file name, or the standard default defined for local
  1599.    users.  The commands may be in any order except that a "rename from"
  1600.    command must be followed by a "rename to" command and the restart
  1601.    command must be followed by the interrupted service command.  The
  1602.    data, when transferred in response to FTP service commands, shall
  1603.    always be sent over the data connection, except for certain
  1604.    informative replies.  The following commands specify FTP service
  1605.    requests:
  1606.  
  1607.       RETRIEVE (RETR)
  1608.  
  1609.          This command causes the server-DTP to transfer a copy of the
  1610.          file, specified in the pathname, to the server- or user-DTP at
  1611.          the other end of the data connection.  The status and contents
  1612.          of the file at the server site shall be unaffected.
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.                                    25
  1622.  
  1623.                                                   File Transfer Protocol
  1624.                                                          (Aug. 12, 1973)
  1625.                                                        RFC 542 NIC 17759
  1626.                                                                         
  1627.                                                                         
  1628.       STORE (STOR)
  1629.  
  1630.          This command causes the server-DTP to accept the data
  1631.          transferred via the data connection and to store the data as a
  1632.          file at the server site.  If the file specified in the pathname
  1633.          exists at the server site then its contents shall be replaced
  1634.          by the data being transferred.  A new file is created at the
  1635.          server site if the file specified in the pathname does not
  1636.          already exist.
  1637.  
  1638.       APPEND (with create) (APPE)
  1639.  
  1640.          This command causes the server-DTP to accept the data
  1641.          transferred via the data connection and to store the data in a
  1642.          file at the server site.  If the file specified in the pathname
  1643.          exists at the server site, then the data shall be appended to
  1644.          that file; otherwise the file specified in the pathname shall
  1645.          be created at the server site.
  1646.  
  1647.       ALLOCATE (ALLO)
  1648.  
  1649.          This command may be required by some servers to reserve
  1650.          sufficient storage to accommodate the new file to be
  1651.          transferred.  The argument shall be a decimal integer
  1652.          representing the number of bytes (using the logical byte size)
  1653.          of storage to be reserved for the file.  For files sent with
  1654.          record structure a maximum record size (in logical bytes) might
  1655.          also be necessary; this is indicated by a decimal integer in a
  1656.          second argument field of the command.  This second argument is
  1657.          optional, but when present should be separated from the first
  1658.          by the three TELNET characters <SP> R <SP>.  This command shall
  1659.          be followed by a STORe or APPEnd command.  The ALLO command
  1660.          should be treated as a NOOP (no operation) by those servers
  1661.          which do not require that the maximum size of the file be
  1662.          declared beforehand, and those servers interested in only the
  1663.          maximum record size should accept a dummy value in the first
  1664.          argument and ignore it.
  1665.  
  1666.       RESTART (REST)
  1667.  
  1668.          The argument field represents the server marker at which file
  1669.          transfer is to be restarted.  This command does not cause file
  1670.          transfer but "spaces" over the file to the specified data
  1671.          checkpoint.  This command shall be immediately followed by the
  1672.          appropriate FTP service command which shall cause file transfer
  1673.          to resume.
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.                                    26
  1683.  
  1684.                                                   File Transfer Protocol
  1685.                                                          (Aug. 12, 1973)
  1686.                                                        RFC 542 NIC 17759
  1687.                                                                         
  1688.                                                                         
  1689.       RENAME FROM (RNFR)
  1690.  
  1691.          This command specifies the file which is to be renamed.  This
  1692.          command must be immediately followed by a "rename to" command
  1693.          specifying the new file pathname.
  1694.  
  1695.       RENAME TO (RNTO)
  1696.  
  1697.          This command specifies the new pathname of the file specified
  1698.          in the immediately preceding "rename from" command.  Together
  1699.          the two commands cause a file to be renamed.
  1700.  
  1701.       ABORT (ABOR)
  1702.  
  1703.          This command indicates to the server to abort the previous FTP
  1704.          service command and any associated transfer of data.  The abort
  1705.          command may require "special action", as discussed in the
  1706.          Section on FTP Commands, to force recognition by the server.
  1707.          No action is to be taken if the previous command has been
  1708.          completed (including data transfer).  The TELNET connections
  1709.          are not to be closed by the server, but the data connection
  1710.          must be closed.  An appropriate reply should be sent by the
  1711.          server in all cases.
  1712.  
  1713.       DELETE (DELE)
  1714.  
  1715.          This command causes the file specified in the pathname to be
  1716.          deleted at the server site.  If an extra level of protection is
  1717.          desired (such as the query, "DO you really wish to delete?"),
  1718.          it should be provided by the user-FTP process.
  1719.  
  1720.       LIST (LIST)
  1721.  
  1722.          This command causes a list to be sent from the server to the
  1723.          passive DTP.  If the pathname specifies a directory, the server
  1724.          should transfer a list of files in the specified directory.  If
  1725.          the pathname specifies a file then the server should send
  1726.          current information on the file.  A null argument implies the
  1727.          user's current working or default directory.  The data transfer
  1728.          is over the data connection in type ASCII or type EBCDIC.  (The
  1729.          user must ensure that the TYPE is appropriately ASCII or
  1730.          EBCDIC).
  1731.  
  1732.       NAME-LIST (NLST)
  1733.  
  1734.          This command causes a directory listing to be sent from server
  1735.          to user site.  The pathname should specify a directory or other
  1736.          system-specific file group descriptor; a null argument implies
  1737.          the current directory.  The server will return a stream of
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.                                    27
  1744.  
  1745.                                                   File Transfer Protocol
  1746.                                                          (Aug. 12, 1973)
  1747.                                                        RFC 542 NIC 17759
  1748.                                                                         
  1749.                                                                         
  1750.          names of files and no other information.  The data will be
  1751.          transferred in ASCII or EBCDIC type over the data connection as
  1752.          valid pathname strings separated by <CRLF> or <NL>.  (Again the
  1753.          user must ensure that the TYPE is correct.)
  1754.  
  1755.       SITE PARAMETERS (SITE)
  1756.  
  1757.          This command is used by the server to provide services specific
  1758.          to his system that are essential to file transfer but not
  1759.          sufficiently universal to be included as commands in the
  1760.          protocol.  The nature of these services and the specification
  1761.          of their syntax can be stated in a reply to the HELP SITE
  1762.          command.
  1763.  
  1764.       STATUS (STAT)
  1765.  
  1766.          This command shall cause a status response to be sent over the
  1767.          TELNET connection in the form of a reply.  The command may be
  1768.          sent during a file transfer (along with the TELNET IP and Synch
  1769.          signals--see the Section on FTP Commands) in which case the
  1770.          server will respond with the status of the operation in
  1771.          progress, or it may be sent between file transfers.  In the
  1772.          latter case the command may have an argument field.  If the
  1773.          argument is a pathname, the command is analogous to the "list"
  1774.          command except that data shall be trasferred over the TELNET
  1775.          connection.  If a partial pathname is given, the server may
  1776.          respond with a list of file names or attributes associated with
  1777.          that specification.  If no argument is given, the server should
  1778.          return general status information about the server FTP process.
  1779.          This should include current values of all transfer parameters
  1780.          and the status of connections.
  1781.  
  1782.       HELP (HELP)
  1783.  
  1784.          This command shall cause the server to send helpful information
  1785.          regarding its implementation status over the TELNET connection
  1786.          to the user.  The command may take an argument (e.g., any
  1787.          command name) and return more specific information as a
  1788.          response.  The reply is type Oxx, general system status.  It is
  1789.          suggested that HELP be allowed before entering a USER command.
  1790.          The server may use this reply to specify site-dependent
  1791.          parameters, e.g., in response to HELP SITE.
  1792.  
  1793.       NOOP (NOOP)
  1794.  
  1795.          This command does not affect any parameters or previously
  1796.          entered commands. It specifies no action other than that the
  1797.          server send a 200 reply.
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.                                    28
  1805.  
  1806.                                                   File Transfer Protocol
  1807.                                                          (Aug. 12, 1973)
  1808.                                                        RFC 542 NIC 17759
  1809.                                                                         
  1810.                                                                         
  1811.    MISCELLANEOUS COMMANDS
  1812.  
  1813.    There are several functions that utilize the services of file
  1814.    transfer but go beyond it in scope.  These are the Mail and Remote
  1815.    Job Entry functions.  It is suggested that these become auxiliary
  1816.    protocols that can assume recognition of file transfer commands on
  1817.    the part of the server, i.e., they may depend on the core of FTP
  1818.    commands.  The command sets specific to Mail and RJE will be given in
  1819.    separate documents.
  1820.  
  1821.    Commands that are closely related to file transfer but not proven
  1822.    essential to the protocol may be implemented by servers on an
  1823.    experimental basis.  The command name should begin with an X and may
  1824.    be listed in the HELP command.  The official command set is
  1825.    expandable from these experiments; all experimental commands or
  1826.    proposals for expanding the official command set should be announced
  1827.    via RFC.  An example of a current experimental command is:
  1828.  
  1829.       Change Working Directory (XCWD)
  1830.  
  1831.          This command allows the user to work with a different directory
  1832.          or dataset for file storage or retrieval without altering his
  1833.          login or accounting information.  Transfer parameters are
  1834.          similarly unchanged.  The argument is a pathname specifying a
  1835.          directory or other system dependent file group designator.
  1836.  
  1837.    FTP REPLIES
  1838.  
  1839.    The server sends FTP replies over the TELNET connection in response
  1840.    to user FTP commands.  The FTP replies constitute the acknowledgment
  1841.    or completion code (including errors).  The FTP-server replies are
  1842.    formatted for human or program interpretation.  Single line replies
  1843.    consist of a leading three-digit numeric code followed by a space,
  1844.    followed by a one-line text explanation of the code.  For replies
  1845.    that contain several lines of text, the first line will have a
  1846.    leading three-digit numeric code followed immediately by the
  1847.    character "-" (Hyphen, ASCII code 45), and possibly some text.  All
  1848.    succeeding continuation lines except the last are constrained NOT to
  1849.    begin with three digits; the last line must repeat the numeric code
  1850.    of the first line and be followed immediately by a space.  For
  1851.    example:
  1852.  
  1853.       100-First Line
  1854.       Continuation Line
  1855.       Another Line
  1856.       100 Last Line
  1857.  
  1858.    It is possible to nest (but not overlap) a reply withiin a multi-line
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.                                    29
  1866.  
  1867.                                                   File Transfer Protocol
  1868.                                                          (Aug. 12, 1973)
  1869.                                                        RFC 542 NIC 17759
  1870.                                                                         
  1871.                                                                         
  1872.    reply.  The same format for matched number-coded first and last lines
  1873.    holds.
  1874.  
  1875.    The numeric codes are assigned by groups and for ease of
  1876.    interpretation by programs in a manner consistent with other
  1877.    protocols such as the RJE protocol.  The three digits of the code are
  1878.    to be interpreted as follows:
  1879.  
  1880.       1. The first digit specifies type of response as indicated below:
  1881.  
  1882.          0xx  These replies are purely informative and constitute
  1883.               neither a positive nor a negative acknowledgment.
  1884.  
  1885.          1xx  Informative replies to status inquiries.  These constitute
  1886.               a positive acknowledgment to the status command.
  1887.  
  1888.          2xx  Positive acknowledgment of previous command or other
  1889.               successful action.
  1890.  
  1891.          3xx  Incomplete information.  Activity cannot proceed without
  1892.               further specification and input.
  1893.  
  1894.          4xx  Unsuccessful reply.  The request is correctly specified
  1895.               but the server is unsuccessful in correctly fulfilling it.
  1896.  
  1897.          5xx  Incorrect or illegal command.  The command or its
  1898.               parameters were invalid or incomplete from a syntactic
  1899.               viewpoint, or the command is inconsistent with a previous
  1900.               command.  The command in question has been completely
  1901.               ignored.
  1902.  
  1903.          6xx-9xx  Reserved for future expansion.
  1904.  
  1905.       2. The second digit specifies the general category to which the
  1906.          response refers:
  1907.  
  1908.          x00-x29  General purpose replies, not assignable to other
  1909.               categories.
  1910.  
  1911.          x3x  Primary access.  Informative replies to the "log-on"
  1912.               attempt.
  1913.  
  1914.          x4x  Secondary access.  The primary server is commenting on its
  1915.               ability to access a secondary service.
  1916.  
  1917.          x5x  FTP results.
  1918.  
  1919.          x6x  RJE results.
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.                                    30
  1927.  
  1928.                                                   File Transfer Protocol
  1929.                                                          (Aug. 12, 1973)
  1930.                                                        RFC 542 NIC 17759
  1931.                                                                         
  1932.                                                                         
  1933.          x7x  Mail Portocol results.
  1934.  
  1935.          x8x-x9x  Reserved for future expansion.
  1936.  
  1937.       3. The final digit specifies a particular message type.  Since the
  1938.          code is designed for an automaton process to interpret, it is
  1939.          not necessary for every variation of a reply to have a unique
  1940.          number.  Only the basic meaning of replies need have unique
  1941.          numbers.  The text of a reply can explain the specific reason
  1942.          for that reply to a human user.
  1943.  
  1944.    Each TELNET line delimited by a numeric code and the TELNET EOL (or
  1945.    group of text lines bounded by coded lines) that is sent by the
  1946.    server is intended to be a complete reply message. It should be noted
  1947.    that the text of replies is intended for a human user. Only the reply
  1948.    codes and in some instances the first line of text are intended for
  1949.    programs.
  1950.  
  1951.    The assigned reply codes relating to FTP are:
  1952.  
  1953.    000  Announcing FTP.
  1954.    010  Message from system operator.
  1955.    020  Exected delay.
  1956.    030  Server availability information.
  1957.    050  FTP commentary or user information.
  1958.    100  System status reply.
  1959.    110  System busy doing...
  1960.    150  File status reply.
  1961.    151  Directory listing reply.
  1962.    200  Last command received correctly.
  1963.    201  An ABORT has terminated activity, as requested.
  1964.    202  Abort request ignored, no activity in progress.
  1965.    230  User is "logged in".  May proceed.
  1966.    231  User is "logged out".  Service terminated.
  1967.    232  Logout command noted, will complete when transfer done.
  1968.    233  User is "logged out".  Parameters reinitialized.
  1969.    250  FTP file transfer started correctly.
  1970.    251  FTP Restart-marker reply.
  1971.       Text is:  MARK yyyy = mmmm
  1972.          where 'yyyy' is user's data stream marker (yours)
  1973.          and mmmm is server's equivalent marker (mine)
  1974.       (Note the spaces between the markers and '=').
  1975.    252  FTP transfer completed correctly.
  1976.    253  Rename completed.
  1977.    254  Delete completed.
  1978.    257  Closing the data connection, transfer completed.
  1979.    300  Connection greeting message, awaiting input.
  1980.    301  Current command incomplete (no <CRLF> for long time).
  1981.    330  Enter password.
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.                                    31
  1988.  
  1989.                                                   File Transfer Protocol
  1990.                                                          (Aug. 12, 1973)
  1991.                                                        RFC 542 NIC 17759
  1992.                                                                         
  1993.                                                                         
  1994.    331  Enter account (if account required as part of login sequence).
  1995.    332  Login first, please.
  1996.    400  This service not implemented.
  1997.    401  This service not accepting users now, goodbye.
  1998.    402  Command not implemented for requested value or action.
  1999.    430  Log-on time or tries exceeded, goodbye.
  2000.    431  Log-on unsuccessful.  User and/or password invalid.
  2001.    432  User not valid for this service.
  2002.    433  Cannot transfer files without valid account.  Enter account and
  2003.         resend command.
  2004.    434  Log-out forced by operator action.  Phone site.
  2005.    435  Log-out forced by system problem.
  2006.    436  Service shutting down, goodbye.
  2007.    450  FTP:  File not found.
  2008.    451  FTP:  File access denied to you.
  2009.    452  FTP:  File transfer incomplete, data connection closed.
  2010.    453  FTP:  File transfer incomplete, insufficient storage space.
  2011.    454  FTP:  Cannot connect to your data socket.
  2012.    455  FTP:  File system error not covered by other reply codes.
  2013.    456  FTP:  Name duplication; rename failed.
  2014.    457  FTP:  Transfer parameters in error.
  2015.    500  Last command line completely unrecognized.
  2016.    501  Syntax of last command is incorrect.
  2017.    502  Last command incomplete, parameters missing.
  2018.    503  Last command invalid (ignored), illegal parameter combination.
  2019.    504  Last command invalid, action not possible at this time.
  2020.    505  Last command conflicts illegally with previous command(s).
  2021.    506  Last command not implemented by the server.
  2022.    507  Catchall error reply.
  2023.    550  Bad pathname specification (e.g., syntax error).
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.                                    32
  2049.  
  2050.                                                   File Transfer Protocol
  2051.                                                          (Aug. 12, 1973)
  2052.                                                        RFC 542 NIC 17759
  2053.                                                                         
  2054.                                                                         
  2055. DECLARATIVE SPECIFICATIONS
  2056.  
  2057.    MINIMUM IMPLEMENTATION
  2058.  
  2059.    In order to make FTP workable without needless error messages, the
  2060.    following minimum implementation is required for servers:
  2061.  
  2062.       
  2063.       TYPE - ASCII Non-print
  2064.       MODE - Stream
  2065.       STRUCTURE - File
  2066.                   Record
  2067.       BYTE - 8
  2068.       COMMANDS - USER, BYE, SOCK,
  2069.                  TYPE, BYTE, MODE, STRU,
  2070.                    for the default values
  2071.                  RETR, STOR,
  2072.                  NOOP.
  2073.       
  2074.  
  2075.    The initial default values for transfer parameters are:
  2076.  
  2077.       
  2078.       TYPE - ASCII Non-print
  2079.       BYTE - 8
  2080.       MODE - Stream
  2081.       STRU - File
  2082.       
  2083.  
  2084.    All Hosts must accept the above as the standard defaults.
  2085.  
  2086.    CONNECTIONS
  2087.  
  2088.    The server protocol interpreter shall "listen" on Socket 3.  The user
  2089.    or user protocol interpreter shall initiate the full-duplex TELNET
  2090.    connections performing the ARPANET standard initial connection
  2091.    protocol (ICP) to server Socket 3.  Server- and user- processes
  2092.    should follow the conventions of the TELNET protocol as specified in
  2093.    NIC #7104.  Servers are under no obligation to provide for editing of
  2094.    command lines and may specify that it be done in the user Host.  The
  2095.    TELNET connections shall be closed by the server at the user's
  2096.    request after all transfers and replies are completed.
  2097.  
  2098.    The user-DTP must "listen" on the specified data sockets (send and/or
  2099.    receive); these may be the default user sockets (U+4) and (U+5) or a
  2100.    socket specified in the SOCK command.  The server shall initiate the
  2101.    data connection from his own fixed sockets (S+2) and (S+3) using the
  2102.    specified user data socket and byte size (default - 8 bits).  The
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.                                    33
  2110.  
  2111.                                                   File Transfer Protocol
  2112.                                                          (Aug. 12, 1973)
  2113.                                                        RFC 542 NIC 17759
  2114.                                                                         
  2115.                                                                         
  2116.    direction of the transfer and the sockets used will be determined by
  2117.    the FTP service command.
  2118.  
  2119.    When data is to be transferred between two servers, A and B (refer to
  2120.    Figure 2), the user-PI, C, sets up TELNET connections with both
  2121.    server-PI's.  He then sends A's fixed sockets, S(A), to B in a SOCK
  2122.    command and B's to A; replies are returned.  One of the servers, say
  2123.    A, is then sent a PASV command telling him to "listen" on his data
  2124.    sockets rather than initiate an RFC when he receives a transfer
  2125.    service command.  When the user-PI receives an acknowledgment to the
  2126.    PASV command, he may send (in either order) the corresponding service
  2127.    commands to A and B.  Server B initiates the RFC and the transfer
  2128.    proceeds.  The command-reply sequence is listed below where the
  2129.    messages are vertically synchronous but horizontally asynchronous:
  2130.  
  2131.       User-PI - Server A                User-PI - Server B
  2132.       ------------------                ------------------
  2133.       
  2134.       C->A : ICP                        C->B : ICP
  2135.       C->A : SOCK HOST-B, SKT-S(B)      C->B : SOCK HOST-A, SKT-S(A)
  2136.       A->C : 200 Okay                   B->C : 200 Okay
  2137.       C->A : PASV
  2138.       A->C : 200 Okay
  2139.       C->A : STOR                       C->B : RETR
  2140.       
  2141.  
  2142.    The data connection shall be closed by the server under the
  2143.    conditions described in the Section on Establishing Data Connections.
  2144.    If the server wishes to close the connection after a transfer where
  2145.    it is not required, he should do so immediately after the file
  2146.    transfer is completed.  He should not wait until after a new transfer
  2147.    command is received because the user-process will have already tested
  2148.    the data connection to see if it needs to do a "listen"; (recall that
  2149.    the user must "listen" on a closed data socket BEFORE sending the
  2150.    transfer request).  To prevent a race condition here, the server
  2151.    sends a secondary reply (257) after closing the data connection (or
  2152.    if the connection is left open, a "file transfer completed" reply
  2153.    (252) and the user-PI should wait for one of these replies before
  2154.    issuing a new transfer command.
  2155.  
  2156.    COMMANDS
  2157.  
  2158.    The commands are TELNET character string transmitted over the TELNET
  2159.    connections as described in the Section on FTP Commands.  The command
  2160.    functions and semantics are described in the Section on Access
  2161.    Control Commands, Transfer Parameter Commands, FTP Service Commands,
  2162.    and Miscellaneous Commands.  The command syntax is specified here.
  2163.  
  2164.    The commands begin with a command code followed by an argument field.
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.                                    34
  2171.  
  2172.                                                   File Transfer Protocol
  2173.                                                          (Aug. 12, 1973)
  2174.                                                        RFC 542 NIC 17759
  2175.                                                                         
  2176.                                                                         
  2177.    The command codes are four or fewer alphabetic characters.  Upper and
  2178.    lower case alphabetic characters are to be treated identically.  Thus
  2179.    any of the following may represent the retrieve command:
  2180.  
  2181.       RETR    Retr    retr    ReTr    rETr
  2182.  
  2183.    This also applies to any symbols representing parameter values, such
  2184.    as A or a for ASCII TYPE.  The command codes and the argument fields
  2185.    are separated by one or more spaces.
  2186.  
  2187.    The argument field consists of a variable length character string
  2188.    ending with the character sequence <CRLF> (Carriage Return, Linefeed)
  2189.    for NVT-ASCII representation; for other negotiated languages a
  2190.    different end of line character might be used.  It should be noted
  2191.    that the server is to take NO action until the end of line code is
  2192.    received.
  2193.  
  2194.    The syntax is specified below in NVT-ASCII.  All characters in the
  2195.    argument field are ASCII characters including any ASCII represented
  2196.    decimal integers.  Square brackets denote an optional argument field.
  2197.    If the option is not taken, the appropriate default is implied.
  2198.  
  2199.    The following are all the currently defined FTP commmands:
  2200.  
  2201.       USER <SP> <username> <CRLF>
  2202.       PASS <SP> <password> <CRLF>
  2203.       ACCT <SP> <acctno> <CRLF>
  2204.       REIN <CRLF>
  2205.       BYE <CRLF>
  2206.       BYTE <SP> <byte size> <CRLF>
  2207.       SOCK <SP> <Host-socket> <CRLF>
  2208.       PASV <CRLF>
  2209.       TYPE <SP> <type code> <CRLF>
  2210.       STRU <SP> <structure code> <CRLF>
  2211.       MODE <SP> <mode code> <CRLF>
  2212.       RETR <SP> <pathname> <CRLF>
  2213.       STOR <SP> <pathname> <CRLF>
  2214.       APPE <SP> <pathname> <CRLF>
  2215.       ALLO <SP> <decimal integer> [<SP> R <SP> <decimal integer>] <CRLF>
  2216.       REST <SP> <marker> <CRLF>
  2217.       RNFR <SP> <pathname> <CRLF>
  2218.       RNTO <SP> <pathname> <CRLF>
  2219.       ABOR <CRLF>
  2220.       DELE <SP> <pathname> <CRLF>
  2221.       LIST [<SP> <pathname>] <CRLF>
  2222.       NLST  [<SP> <pathname>] <CRLF>
  2223.       SITE <SP> <string> <CRLF>
  2224.       STAT [<SP> <pathname>] <CRLF>
  2225.       HELP [<SP> <string>] <CRLF>
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.                                    35
  2232.  
  2233.                                                   File Transfer Protocol
  2234.                                                          (Aug. 12, 1973)
  2235.                                                        RFC 542 NIC 17759
  2236.                                                                         
  2237.                                                                         
  2238.       NOOP <CRLF>
  2239.  
  2240.    The syntax of the above argument fields (using BNF notation where
  2241.    applicable ) is:
  2242.  
  2243.       <username> ::= <string>
  2244.       <password> ::= <string>
  2245.       <acctno> ::= <string>
  2246.       <string> ::= <char>|<char><string>
  2247.       <char> ::= any of the 128 ASCII characters except <CR> and <LF>
  2248.       <marker> ::= <pr string>
  2249.       <pr string> ::= <pr char>|<pr char><pr string>
  2250.       <pr char> ::= any ASCII code 33. through 126., printable
  2251.          characters
  2252.       <byte size> ::= any decimal integer 1 through 255
  2253.       <Host-socket> ::= <socket>|<Host number>, <socket>
  2254.       <Host-number> ::= a decimal integer specifying an ARPANET Host.
  2255.       <socket> ::= decimal integer between 0 and (2**32)-1
  2256.       <form code> ::= N|T|C
  2257.       <type code> ::= A[<SP> <form code>]|E [SP> <form code>]|I|
  2258.       L <SP> <byte size>
  2259.       <structure code> ::= F|R
  2260.       <mode code> ::= S|B|C
  2261.       <pathname> ::= <string>
  2262.  
  2263.    SEQUENCING OF COMMANDS AND REPLIES
  2264.  
  2265.    The communication between the user and server is intended to be an
  2266.    alternating dialogue.  As such, the user issues an FTP command and
  2267.    the server responds with a prompt primary reply.  The user should
  2268.    wait for this initial primary success or failure response before
  2269.    sending further commands.
  2270.  
  2271.    Certain commands require a second reply for which the user should
  2272.    also wait.  These replies may, for example, report on the progress or
  2273.    completion of file transfer or the closing of the data connection.
  2274.    They are secondary replies to file transfer commands.
  2275.  
  2276.    The third class of replies are informational and spontaneous replies
  2277.    which may arrive at any time.  The user-PI should be prepared to
  2278.    receive them.  These replies are listed below as sponteneous.
  2279.  
  2280.    One important group of spontaneous replies is the connection
  2281.    greetings.  Under normal circumstances, a server will send a 300
  2282.    reply, "awaiting input", when the ICP is completed.  The user should
  2283.    wait for this greeting message before sending any commands.  If the
  2284.    server is unable to accept input right away, he should send a 000
  2285.    "announcing FTP" or a 020 "expected delay" reply immediately and a
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.                                    36
  2293.  
  2294.                                                   File Transfer Protocol
  2295.                                                          (Aug. 12, 1973)
  2296.                                                        RFC 542 NIC 17759
  2297.                                                                         
  2298.                                                                         
  2299.    300 reply when ready.  The user will then know not to hang up if
  2300.    there is a delay.
  2301.  
  2302.    The table below lists alternative success and failure replies for
  2303.    each command.  These must be strictly adhered to; a server may
  2304.    substitute text in the replies, but the meaning and action implied by
  2305.    the code numbers and by the specific command reply sequence cannot be
  2306.    altered.
  2307.  
  2308.                    COMMAND-REPLY CORRESPONDENCE TABLE
  2309.  
  2310.    COMMAND             SUCCESS         FAILURE
  2311.  
  2312.    USER                230,330         430-432,500-505,507
  2313.    PASS                230,330         430-432,500-507
  2314.    ACCT                230             430-432,500-507
  2315.    REIN                232,233         401,436,500-507
  2316.       Secondary Reply  300
  2317.    BYE                 231,232         500-505,507
  2318.    BYTE                200,331         402,500-505,507
  2319.    SOCK                200,331         500-505,507
  2320.    PASV                200,331         500-507
  2321.    TYPE                200,331         402,500-505,507
  2322.    STRU                200,331         500-505,507
  2323.    MODE                200,331         402,500-505,507
  2324.    RETR                250             402,433,450,451,454,455,457,
  2325.                                          500-505,507,550
  2326.       Secondary Reply  252,257         452
  2327.    STOR                250             402,433,451,454,455,457,
  2328.                                          500-505,507,550
  2329.       Secondary Reply  252,257         452,453
  2330.    APPE                250             402,433,451,454,455,457,500-507,
  2331.                                          550
  2332.       Secondary Reply  252,257         452,453
  2333.    ALLO                200,331         402,500-507
  2334.    REST                200,331         500-507
  2335.    RNFR                200             402,433,450,451,455,500-507,550
  2336.    RNTO                253             402,433,450,451,455,456,500-507,
  2337.                                          550
  2338.    ABOR                201,202,331     500-507
  2339.    DELE                254             402,433,450,451,455,500-507,550
  2340.    LIST                250             402,433,450,451,454,455,457,
  2341.                                          500-507,550
  2342.       Secondary Reply  252,257         452
  2343.    NLST                250             402,433,450,451,454,455,457,
  2344.                                          500-507,550
  2345.       Secondary Reply  252,257         452
  2346.    SITE                200,331         402,500-507
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.                                    37
  2354.  
  2355.                                                   File Transfer Protocol
  2356.                                                          (Aug. 12, 1973)
  2357.                                                        RFC 542 NIC 17759
  2358.                                                                         
  2359.                                                                         
  2360.    STAT                100,110,        450,451,455,500-507,550
  2361.                          150,151,331
  2362.    HELP                030,050         500-507
  2363.    NOOP                200             500-505,507
  2364.    Spontaneous Replies 000,010,020,    400,401,434-436
  2365.                          300,301,251,255
  2366.  
  2367.    TYPICAL FTP SCENARIOS
  2368.  
  2369.    TIP User wanting to transfer file from Host X to local printer:
  2370.  
  2371.       1. TIP user opens TELNET connections by ICP to Host X socket 3.
  2372.  
  2373.       2. The following commands and replies are exchanged:
  2374.  
  2375.          TIP                       HOST X
  2376.  
  2377.          <---------- 300 Awaiting input <CRLF>
  2378.          USER username <CRLF> ---------->
  2379.          <---------- 330 Enter Password <CRLF>
  2380.          PASS password <CRLF> ---------->
  2381.          <---------- 230 User logged in <CRLF>
  2382.          SOCK 65538 <CRLF> ---------->
  2383.          <---------- 200 Commmand received OK<CRLF>
  2384.          RETR this.file <CRLF> ---------->
  2385.             (Host X initiates data connection to TIP socket 65538,
  2386.              i.e., PORT 1 receive)
  2387.          <---------- 250 File transfer started <CRLF>
  2388.          <---------- 252 File transfer completed <CRLF>
  2389.          BYE<CRLF>         ---------->
  2390.          <---------- 231 User logged out <CRLF>
  2391.  
  2392.       3. Host X closes the TELNET and data connections.
  2393.  
  2394.          Note: The TIP user should be in line mode.
  2395.  
  2396.    User at Host U wanting to transfer files to/from Host S:
  2397.  
  2398.    In general the user will communicate to the server via a mediating
  2399.    user-FTP process.  The following may be a typical scenario.  The
  2400.    user-FTP prompts are shown in parentheses, '---->' represents
  2401.    commands from Host U to Host S, and '<----' represents replies from
  2402.    Host S to Host U.
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.                                    38
  2415.  
  2416.                                                   File Transfer Protocol
  2417.                                                          (Aug. 12, 1973)
  2418.                                                        RFC 542 NIC 17759
  2419.                                                                         
  2420.                                                                         
  2421.       LOCAL COMMANDS BY USER              ACTION INVOLVED
  2422.  
  2423.       ftp (host) multics<CR>         ICP to Host S, socket 3,
  2424.                                      establishing TELNET connections
  2425.                                      <---- 330 Awaiting input <CRLF>
  2426.       username Doe <CR>              USER Doe<CRLF>---->
  2427.                                      <---- 330 password<CRLF>
  2428.       password mumble <CR>           PASS mumble<CRLF>---->
  2429.                                      <---- 230 Doe logged in.<CRLF>
  2430.       retrieve (local type) ASCII<CR>
  2431.       (local pathname) test 1 <CR>   User-FTP opens local file in ASCII.
  2432.       (for.pathname) testp11<CR>     RETR test.p11<CRLF> ---->
  2433.                                      Server makes data connection to
  2434.       (U+4)
  2435.                                      <---- 250 File transfer starts
  2436.       <CRLF>
  2437.                                      <---- 252 File transfer
  2438.       complete<CRLF>
  2439.       type Image<CR>                 TYPE I<CRLF> ---->
  2440.                                      <---- 200 Command OK<CRLF>
  2441.       byte 36<CR>                    BYTE 36<CR>LF ---->
  2442.                                      <---- 200 Command OK<CRLF>
  2443.       store (local type) image<CR>
  2444.       (local pathname) file dump<CR> User-FTP opens local file in Image.
  2445.       (for.pathname) >udd>cn>fd<CR>  STOR >udd>cn>fd<CRLF> ---->
  2446.                                      <---- 451 Access denied<CRLF>
  2447.       terminate                      BYE <CRLF> ---->
  2448.                                      Server closes all connections.
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.                                    39